package com.haoshuang.zhouzhoubang.ui.page.shop.child

import com.blankj.utilcode.util.SizeUtils
import com.chad.library.adapter4.BaseQuickAdapter
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemGoodsListBinding
import com.haoshuang.zhouzhoubang.databinding.ItemStudyArticleListBinding
import com.haoshuang.zhouzhoubang.model.bean.ShopBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.SpannableStringUtils
import com.mufeng.libs.utils.view.load

/**
 * 商城中的商品列表适配器
 * */
class ShoppingRecyclerViewAdapter(data: MutableList<ShopBean>) :
    BaseBindingQuickAdapter<ShopBean, ItemGoodsListBinding>(data) {

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: ShopBean?) {
        holder.getViewBinding<ItemGoodsListBinding>().apply {
            tvGoodsName.text = item?.store_name
            riGoodsImage.load(item?.image)
            val price = SpannableStringUtils(context, "￥${item?.price}")
                .first("￥")
                .size(SizeUtils.px2dp(SizeUtils.sp2px(12.0f).toFloat()))

            tvGoodsPrice.text = price
        }
    }

}